///*
// *    Copyright (c) 2018-2025, lengleng All rights reserved.
// *
// * Redistribution and use in source and binary forms, with or without
// * modification, are permitted provided that the following conditions are met:
// *
// * Redistributions of source code must retain the above copyright notice,
// * this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// * notice, this list of conditions and the following disclaimer in the
// * documentation and/or other materials provided with the distribution.
// * Neither the name of the pig4cloud.com developer nor the names of its
// * contributors may be used to endorse or promote products derived from
// * this software without specific prior written permission.
// * Author: lengleng (wangiegie@gmail.com)
// */
//
//package com.excesys.exsecs.om.controller;
//
//import cn.hutool.core.io.IoUtil;
//import cn.hutool.core.util.StrUtil;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.excesys.exsecs.common.core.util.R;
//import com.excesys.exsecs.common.log.annotation.SysLog;
//import com.excesys.exsecs.common.security.annotation.Inner;
//import com.excesys.exsecs.om.entity.OmOFile;
//import com.excesys.exsecs.om.service.OmOFileService;
//import io.swagger.v3.oas.annotations.Operation;
//import io.swagger.v3.oas.annotations.security.SecurityRequirement;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import lombok.RequiredArgsConstructor;
//import lombok.SneakyThrows;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.http.HttpHeaders;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletResponse;
//
///**
// * 文件管理表
// *
// * @author weiyj
// * @date 2023-02-24 13:52:55
// */
//@RestController
//@RequiredArgsConstructor
//@RequestMapping("/omofile")
//@Tag(name = "文件管理表管理")
//@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
//public class OmOFileController {
//
//	private final OmOFileService omOFileService;
//
//	/**
//	 * 分页查询
//	 * @param page 分页对象
//	 * @param omOFile 文件管理
//	 * @return
//	 */
//	@Operation(summary = "分页查询", description = "分页查询")
//	@GetMapping("/page")
//	public R<IPage<OmOFile>> getSysFilePage(Page page, OmOFile omOFile) {
//		return R.ok(omOFileService.page(page,
//				Wrappers.<OmOFile>lambdaQuery()
//						.like(StrUtil.isNotBlank(omOFile.getFileName()), OmOFile::getFileName, omOFile.getFileName())
//						.like(StrUtil.isNotBlank(omOFile.getOriginal()), OmOFile::getOriginal, omOFile.getOriginal())
//						.like(StrUtil.isNotBlank(omOFile.getType()), OmOFile::getType, omOFile.getType())
//						.like(StrUtil.isNotBlank(omOFile.getCreateBy()), OmOFile::getCreateBy, omOFile.getCreateBy())));
//	}
//
//	/**
//	 * 通过id删除文件管理
//	 * @param id id
//	 * @return R
//	 */
//	@Operation(summary = "通过id删除文件管理", description = "通过id删除文件管理")
//	@SysLog("删除文件管理")
//	@DeleteMapping("/{id:\\d+}")
//	@PreAuthorize("@pms.hasPermission('om_omofile_del')")
//	public R<Boolean> removeById(@PathVariable Long id) {
//		return R.ok(omOFileService.deleteFile(id));
//	}
//
//	/**
//	 * 上传文件 文件名采用uuid,避免原始文件名中带"-"符号导致下载的时候解析出现异常
//	 * @param file 资源
//	 * @return R(/ admin / bucketName / filename)
//	 */
//	@PostMapping(value = "/upload")
//	public R upload(@RequestPart("file") MultipartFile file) {
//		return omOFileService.uploadFile(file);
//	}
//
//	/**
//	 * 获取文件
//	 * @param bucket 桶名称
//	 * @param fileName 文件空间/名称
//	 * @param response
//	 * @return
//	 */
//	@Inner(false)
//	@GetMapping("/{bucket}/{fileName}")
//	public void file(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) {
//		omOFileService.getFile(bucket, fileName, response);
//	}
//
//	/**
//	 * 获取本地（resources）文件
//	 * @param fileName 文件名称
//	 * @param response 本地文件
//	 */
//	@SneakyThrows
//	@GetMapping("/local/{fileName}")
//	public void localFile(@PathVariable String fileName, HttpServletResponse response) {
//		ClassPathResource resource = new ClassPathResource("file/" + fileName);
//		response.setContentType("application/octet-stream; charset=UTF-8");
//		IoUtil.copy(resource.getInputStream(), response.getOutputStream());
//	}
//
//	/**
//	 * 获取文件外网的访问地址
//	 * @param bucket
//	 * @param fileName
//	 * @return
//	 */
//	@Inner(false)
//	@GetMapping("/online/{bucket}/{fileName}")
//	public R<String> onlineFile(@PathVariable String bucket, @PathVariable String fileName) {
//		return R.ok(omOFileService.onlineFile(bucket, fileName));
//	}
//
//}
